package com.neusoft.resturant.mapper;

import com.neusoft.resturant.entity.ResDishes;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ResDishesMapper {

    /**
     * 查询菜品
     */
    @Select("select id, name, pic, description, price, category, shop_id, create_by, create_time, update_by, update_time from res_dishes where id = #{id}")
    public ResDishes selectResDishesById(Long id);

    /**
     * 查询菜品列表
     */
    @Select("select id, name, pic, description, price, category, shop_id, create_by, create_time, update_by, update_time from res_dishes where name like concat('%', #{name}, '%') and shop_id = #{shopId}")
    public List<ResDishes> selectResDishesList(ResDishes resDishes);

    /**
     * 新增菜品
     */
    @Insert("insert into res_dishes(name, pic, description, price, category, shop_id, create_by, create_time) values(#{name},#{pic},#{description},#{price},#{category},#{shopId},#{createBy},now())")
    public int insertResDishes(ResDishes resDishes);

    /**
     * 修改菜品
     */
    @Update("update res_dishes set name = #{name}, price=#{price}, category=#{category}, update_time = now() where id = #{id}")
    public int updateResDishes(ResDishes resDishes);

    /**
     * 删除菜品
     * 可以用@param起别名
     */
    @Delete("delete from res_dishes where id = #{did}")
    public int deleteResDishesById(@Param("did") Long id);



}
